home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -in_the_mag- / reader_requests / wild / support / wilf / modules / meta.c < prev    next >
C/C++ Source or Header  |  2000-02-23  |  2KB  |  83 lines

  1. #include <meta.h>
  2. #include <inline/exec.h>
  3. #include <exec/exec.h>
  4. #include <exec/lists.h>
  5.  
  6. extern struct ExecBase *SysBase;
  7.  
  8. void CommonInit(struct Common *com,struct Common *par)
  9. {
  10.  NewList(com->com_Attrs); 
  11.  NewList(com->com_Childs); 
  12.  if (par) 
  13.   {AddTail(&par->com_Childs,&com->com_Node);}
  14. }
  15.  
  16. struct Meta *NewMeta(struct Common *parent)             // parent may be 0
  17. {ULONG *pool; 
  18.  struct Meta *meta;
  19.  pool=CreatePool(MEMF_CLEAR+MEMF_ANY,32768,16384); 
  20.  meta=AllocPooled(pool,sizeof(struct Meta)); 
  21.  CommonInit(meta,parent); 
  22.  meta->meta_Pool=pool;
  23.  NewList(meta->meta_Flags); 
  24.  return(meta);
  25. }
  26.  
  27. struct Group *NewGroup(struct Meta *meta,char *type)
  28. {
  29.  struct Group *group;
  30.  group=AllocMetaMem(meta,sizeof(struct Group)); 
  31.  CommonInit(group,meta); 
  32.  CopyWord((struct Group *)&group->group_Type,type); 
  33.  return(group);
  34. }
  35.  
  36. struct Entity *NewEntity(struct Group *group,struct Meta *meta,int ID) 
  37. {
  38.  struct Entity *enty;
  39.  enty=AllocMetaMem(meta,sizeof(struct Entity)); 
  40.  CommonInit(enty,group); 
  41.  enty->entity_ID=ID; 
  42.  return(enty);
  43. }
  44.  
  45. struct Attr *GenAttr(struct Meta *meta,char *name,char *value)
  46. {
  47.  struct Attr *attr;
  48.  attr=AllocMetaMem(meta,sizeof(struct Attr)); 
  49.  CopyWord(&attr->attr_Name,name); 
  50.  CopyStr(&attr->attr_Value,value); 
  51.  return(attr);
  52. }
  53.  
  54. struct Attr *NewAttr(struct Common *com,struct Meta *meta,char *name,char *value)
  55. {
  56.  struct Attr *attr;
  57.  attr=GenAttr(meta,name,value);
  58.  AddTail(&com->com_Attrs,&attr->attr_Node); 
  59.  return(attr);
  60. }
  61.  
  62. struct Attr *NewFlag(struct Meta *meta,char *name,char *value)
  63. {
  64.  struct Attr *attr;
  65.  attr=GenAttr(meta,name,value);
  66.  AddTail(&meta->meta_Flags,&attr->attr_Node);
  67.  return(attr);
  68. }
  69.  
  70. char *HaveAttrValue(struct Common *com,char *name)
  71. {
  72.  struct Attr *catt,*natt;
  73.  catt=com->com_Attrs.mlh_Head;
  74.  while (natt=catt->attr_Node.mln_Succ)
  75.   {
  76.    if (StrCmp(catt->attr_Name,name))
  77.     {return(catt->attr_Value);}
  78.    catt=natt;
  79.   }
  80.  return(FALSE);
  81. }
  82.  
  83.